package siruna.WE.DeviceDependent;

import java.net.InetAddress;
import java.net.UnknownHostException;

import android.app.Activity;
import android.app.ActivityManager;
import android.app.ActivityManager.MemoryInfo;
import android.content.Context;
import android.os.Build;
import android.util.DisplayMetrics;

public class DeviceInfo {
	Activity ac;

	public DeviceInfo(Activity ac) {

		this.ac = ac;
	}

	String getIpAdres() {
		InetAddress addr = null;
		try {
			addr = InetAddress.getLocalHost();
		} catch (UnknownHostException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return addr.getHostAddress();
	}

	public int getScreenHeight() {

		DisplayMetrics dm = new DisplayMetrics();

		ac.getWindowManager().getDefaultDisplay().getMetrics(dm);

		return (dm.heightPixels);

	}

	public int getScreenWidth() {

		DisplayMetrics dm = new DisplayMetrics();

		ac.getWindowManager().getDefaultDisplay().getMetrics(dm);

		return dm.widthPixels;

	}

	String getMemSize() {

		ActivityManager mgr = (ActivityManager) ac
				.getSystemService(Context.ACTIVITY_SERVICE);
		MemoryInfo memInfo = new ActivityManager.MemoryInfo();
		mgr.getMemoryInfo(memInfo);

		return Long.toString(memInfo.availMem / 1048576);

	}

	String getName() {
		// eventueel aanpassen na testen op een echt toestel !
		/*
		 * System.out.println("board: "+b.BOARD);
		 * System.out.println("brand: "+b.BRAND);
		 * System.out.println("device: "+b.DEVICE);
		 * System.out.println("Fingerprint: "+b.FINGERPRINT);
		 * System.out.println("host: "+b.HOST);
		 * 
		 * System.out.println("id: "+b.ID);
		 * System.out.println("model: "+b.MODEL);
		 * System.out.println("product: "+b.PRODUCT);
		 * System.out.println("tags: "+b.TAGS);
		 * 
		 * System.out.println("time: "+b.TIME);
		 * 
		 * System.out.println("type: "+b.TYPE);
		 * System.out.println("user: "+b.USER);
		 */

		// return b.BOARD + " " + b.BRAND+ " " + b.DEVICE+ " " + b.FINGERPRINT+
		// " " + b.HOST+ " " + b.ID+
		// " " + b.MODEL+" " + b.PRODUCT+" " + b.TAGS+" " + b.TIME+" " +
		// b.TYPE+" " + b.USER;
		return "Android: " + Build.BRAND + " " + Build.MODEL;
	}
}
